(editorconfig-set-local-variables): Get first, set later
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 10 Jun 2024 20:58:27 +0000 (16:58 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 19 Jun 2024 18:39:17 +0000 (14:39 -0400)
commitf2803456f029f24276901c2b3115965d892a99d0
treebf4ae517cdf3fdefdaad01fb266df38ff10b83c9
parent527a45abc37f1885652b0f29ed5eeabff6db6cda
(editorconfig-set-local-variables): Get first, set later

In preparation for the use of Emacs-30's
`hack-dir-local-get-variables-functions`, split the job of
`editorconfig-set-local-variables` into getting an alist of settings
and then applying them.

Rename the `editorconfig-set-*` functions to `editorconfig--get-*`
and make them return an alist of settings rather than applying them
(except for `editorconfig-set-coding-system-revert` which arguably
belongs in `editorconfig-tools.el` anyway).

* lisp/editorconfig.el (editorconfig-indentation-alist): Flesh out the doc.
Use the new `editorconfig--get-indentation-*-mode` functions.
(editorconfig--get-indentation-web-mode): New function extracted from
`editorconfig-indentation-alist`.
(editorconfig--get-indentation-*-mode): Don't `boundp`-test the vars.
(editorconfig--default-indent-size-function): New function.
Test `boundp` here.
(editorconfig-indent-size-vars): New var.
(editorconfig--get-indentation, editorconfig--get-trailing-nl): Rewrite.
(editorconfig--add-hook-safe-p): New function.
Add it to the `safe-local-eval-function` property of `add-hook`.
(editorconfig-get-local-variables-functions): New hook.
(editorconfig--get-local-variables): Rewrite using it.
(editorconfig-set-local-variables): Test `editorconfig--should-set` here.
Rewrite it using `editorconfig--get-local-variables`.
lisp/editorconfig.el